<template>
    <view class="content" v-if="isShow">
        <view class="wrapper">
            <view class="u-m-b-20">
                <u-search placeholder="输入发货方联系方式或姓名或产品名称" v-model="keyword" :show-action="false" bg-color="#fff" @search="doSearch"></u-search>
            </view>
            
            <view class="box" v-for="(item, index) in list" :key="index" 
                @click="$gTo(`/pages/abnormal/list-2?id=${item.id}`)">
                <view class="top">
                    <view class="item u-flex-1">
                        <view class="i-left">运单编号</view>
                        <view class="i-right">{{item.out_trade_no}}</view>
                    </view>
					<view class="o-sta1" v-if="item.order_type == 1">零担</view>
					<view class="o-sta2" v-if="item.order_type == 2">包车</view>
                </view>
                <view class="item">
                    <view class="i-left">运输线路</view>
                    <view class="i-right">{{item.line}}</view>
                </view>
                <view class="item">
                    <view class="i-left">司机</view>
                    <view class="i-right">{{item.name}}</view>
                </view>
                <view class="item">
                    <view class="i-left">车牌号</view>
                    <view class="i-right">{{item.number}}</view>
                </view>
                <view class="item">
                    <view class="i-left">联系方式</view>
                    <view class="i-right">{{item.phone}}</view>
                </view>
                <view class="item">
                    <view class="i-left">始发地</view>
                    <view class="i-right">{{item.origin}}</view>
                </view>
                <view class="item">
                    <view class="i-left">目的地</view>
                    <view class="i-right">{{item.destination}}</view>
                </view>
                <view class="item">
                    <view class="i-left">装车地点</view>
                    <view class="i-right">{{item.loading_site}}</view>
                </view>
                
                <!-- 零担 -->
                <view class="item" v-if="item.kilometer_img">
                    <view class="i-left">货物摆放图</view>
                    <view class="i-right">
                        <image :src="item.kilometer_img" class="img"></image>
                    </view>
                </view>
                
                <view class="item" v-if="item.seal_img">
                    <view class="i-left">发车签封</view>
                    <view class="i-right">
                        <image :src="item.seal_img" class="img"></image>
                    </view>
                </view>
                <view class="item" v-if="item.all_num">
                    <view class="i-left">实际总件数</view>
                    <view class="i-right">{{item.all_num}}件</view>
                </view>
                <view class="item" v-if="item.all_weight">
                    <view class="i-left">实际总重量</view>
                    <view class="i-right">{{item.all_weight}}斤</view>
                </view>
                <view class="item" v-if="item.weigh">
                    <view class="i-left">过磅总重量</view>
                    <view class="i-right">{{item.weigh}}吨</view>
                </view>
				<view class="item" v-if="item.load_start_time">
				    <view class="i-left">装车开始时间</view>
				    <view class="i-right">{{item.load_start_time}}</view>
				</view>
				<view class="item" v-if="item.load_end_time">
				    <view class="i-left">装车结束时间</view>
				    <view class="i-right">{{item.load_end_time}}</view>
				</view>
				<view class="item" v-if="item.start_date">
				    <view class="i-left">发车时间</view>
				    <view class="i-right">{{item.start_date}}</view>
				</view>
				<view class="item" v-if="item.expect_time">
				    <view class="i-left">预计到达时间</view>
				    <view class="i-right">{{item.expect_time}}</view>
				</view>
				<view class="item" v-if="item.arrival_time">
				    <view class="i-left">司机到达时间</view>
				    <view class="i-right">{{item.arrival_time}}</view>
				</view>
				<view class="item" v-if="item.unload_time">
				    <view class="i-left">卸车开始时间</view>
				    <view class="i-right">{{item.unload_time}}</view>
				</view>
				<view class="item" v-if="item.finish_time">
				    <view class="i-left">卸车结束时间</view>
				    <view class="i-right">{{item.finish_time}}</view>
				</view>
            </view>
			
			<view style="height: 94rpx;padding-top: 30rpx;">
			    <u-loadmore :status="status" v-if="status != 'loadmore'" />
			</view>
        </view>
    </view>
</template>

<script>
    export default {
        data() {
            return {
                keyword: '',
                status: 'loadmore', //是否显示没有更多了
                page: 1,
                list: [],
				isShow: false,
            };
        },
        onLoad() {
            this.getList()
        },
		onReachBottom() {
			if(this.page == 1){return}
			this.getList()
		},
        methods: {
            doSearch() {
            	this.list = []
            	this.page = 1
            	this.status = 'loadmore'
            	this.getList()
            },
            
            getList() {
            	if (this.status == 'nomore') return;
            	this.status = 'loading';
            	this.$ajax('unload_waybill', {
            		user_token: this.$getSync('userToken'),
            		page: this.page,
            		limit: 10,
                    status: 8,//6待卸货 7已完成 8异常订单
            		name: this.keyword,
            	}).then(ret => {
            		if (ret.success == 1000) {
            			if (ret.detail && ret.detail.orders && ret.detail.orders.length > 0) {
            				this.list = this.list.concat(ret.detail.orders);
            				this.page++;
            				this.status = 'loadmore'
            			} else {
            				this.status = 'nomore'
            			}
            			this.isShow = true
            		} else {
            			this.$toast(ret.msg);
            		}
            	});
            },
        }
    };
</script>

<style lang="scss">
    .box{
        background-color: #fff;
        border-radius: 15rpx;
        padding: 40rpx 30rpx 30rpx;
        margin: 16rpx 0 0;
    }
    .top{
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .item{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 10rpx;
    }
    .i-left{
        width: 185rpx;
        color: #656565;
    }
    .i-right{
        flex: 1;
        word-break: break-all;
        white-space: pre-line;
    }
    .o-sta1{
        font-size: 24rpx;
        color: #ff602c;
        padding: 7rpx 15rpx;
        background-color: #fff1ec;
        border-radius: 10rpx;
        margin-left: 10rpx;
        margin-bottom: 10rpx;
    }
    .o-sta2{
        font-size: 24rpx;
        color: #0075ff;
        padding: 7rpx 15rpx;
        background-color: #ebf4fe;
        border-radius: 10rpx;
        margin-left: 10rpx;
        margin-bottom: 10rpx;
    }
    .img{
        width: 240rpx;
        height: 170rpx;
    }
    
    
    page{
        background-color: #eef1f6;
    }
    .wrapper{
        padding: 20rpx;
    }
    .box3{
        background-color: #fff;
        border-radius: 20rpx;
        padding: 40rpx 30rpx 30rpx;
        margin-bottom: 15rpx;
    }
    .item2{
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: 10rpx;
    }
    .title{
        font-size: 30rpx;
        font-weight: bold;
        padding-bottom: 15rpx;
    }
    .left{
        width: 140rpx;
        color: #656565;
    }
    .right{
        flex: 1;
        word-break: break-all;
        white-space: pre-line;
    }
    .btns2{
        padding-top: 10rpx;
        display: flex;
        justify-content: space-between;
        align-items: center;
        color: #fff;
    }
    .btn1{
        padding: 15rpx 50rpx;
        background-color: #004580;
        border-radius: 50rpx;
        margin-left: 20rpx;
    }
    .btn5{
    	color: #ff5f2b;
        // padding: 15rpx 25rpx;
        // background-color: #ff5f2b;
        // border-radius: 50rpx;
        // margin-left: 20rpx;
    }

</style>
